<template>
  <div class="newsiinfo-container">
    <h3 class="title">{{newinfo.title}}</h3>
    <p class="subtitle">
      <span>发表时间：{{newinfo.add_time | dateFormat}}</span>
      <span>点击：{{newinfo.click}}</span>
    </p>
    <hr>
    <div class="content" v-html="newinfo.content"></div>
    <!-- 评论子组件 -->
    <comment :id="this.id"></comment>
  </div>
</template>
<script>
// 导入评论组件
import comment from '../subComent/comment.vue'
export default {
  data() {
    return {
      id:this.$route.params.id,   // 通过浏览器vue可以找到$router params id 
      newinfo:{}
    };
  },
  created() {
    this.getnewsinfo();
  },
  components:{
    comment,  // 注册
  },
  methods: {
    getnewsinfo(){
      this.$http.get('http://www.liulongbin.top:3005/api/getnew/'+this.id).then(res=>{
        // console.log(res)
        if(res.body.status == 0){
          this.newinfo = res.body.message[0];
        }
      })
    }
  },
}
</script>
<style lang="scss" scoped>
  .newsiinfo-container {
    padding: 0 5px;
    h3 {
      font-size: 16px;
      text-align: center;
    }
    .subtitle {
      display: flex;
      justify-content: space-between;
    }
  }
</style>